package com.xzp.gkrpc.server;

import com.xzp.gkrpc.Request;
import com.xzp.gkrpc.common.utils.ReflectionUtils;

import java.lang.reflect.InvocationTargetException;

public class ServiceInvoker {
    /**
     * 调用某个实例的某个方法
     * @param service
     * @param request
     * @return
     */
    public Object invoke(ServiceInstance service, Request request) throws InvocationTargetException, IllegalAccessException {
        return ReflectionUtils.invoke(service.getTarget(), service.getMethod(), request.getParameters());
    }
}
